package com.bdqn.controller;

import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import java.io.IOException;

public class Demo3 {
    public static void main(String[] args) {
        DocumentBuilderFactory dbf=DocumentBuilderFactory.newInstance();

        DocumentBuilder db;

        {
            try {
                db = dbf.newDocumentBuilder();
                Document doc=db.parse("src/main/resources/收藏信息.xml");
                NodeList list=doc.getElementsByTagName("pubDate");
                Element pubDateElement=(Element)list.item(0);
                String pubDate=pubDateElement.getFirstChild().getNodeValue();
                System.out.println(pubDate);
            } catch (ParserConfigurationException e) {
                e.printStackTrace();
            } catch (SAXException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }

}
